/******************************************************************************
 * ServoController
 *
 * Description:
 *  This class interfaces with the servo motors via the PWM ports. The PWM
 *  channels were initialized. Other classes can change the duty cycle of
 *  individual motors using the SetPosition function.
 *
 * 
 * Authors:
 *  Ariana Hong    (9/20/2011)
 *  Russell Martin (9/20/2011)
 *
 *****************************************************************************/

#ifndef SERVO_CONTROLLER_H
#define SERVO_CONTROLLER_H

#include <hidef.h>      /* common defines and macros */
#include "Types.h"
#include "Derivative.h" /* derivative-specific definitions */

//Duty values corresponding to how many PWM clock ticks
// refer to duty values between ~1ms and 2ms,
// which allow the servo to move back and forth
// Since 250 refers to 20ms, the full period, 25 = 2ms,
// and 12 is approximately 1ms. These values may need to be changed
// based on each servo, in order to calibrate to position markings.
#define POS0          ((UINT16)2000)
#define POS5          ((UINT16)4500)
#define POSITION_MAX  (127)
#define POSITION_MULT ((UINT16)20) // (POS5 - POS0) / POSITION_MAX

// Initializes PWM settings
//--------------------------------------------------------------       
void InitalizePWM(void);

void SetPosition(INT8 value);

#endif /* SERVO_CONTROLLER_H */